*** Do-file to replicate figures shown in
*   Bodea, Cristina and Ana Carolina Garriga
*   Central bank independence in Latin America: Politicization and de-delegation
*   Governance, 2022


****************************
* Figure 1: Regional average and reforms per year and direction. 
****************************

use "/Users/.../Reversals_collapsed data.dta", clear

sort year

twoway (bar increase year, sort fcolor(gs10) lcolor(black) barwidth(.75)) ///
	   (bar decrease year, sort fcolor(gs2) lcolor(black) barwidth(.75)) ///
	    (line lvaw_garriga year, yaxis(2) lcolor(cranberry) lwidth(medium) lpattern(solid)),  ///
        yline(0, lcolor(black)) yscale(range(0(.1)1) axis(2))  ytitle(Number of reforms (bars), size(medsmall)) ///
		ytitle(Average CBI index, axis(2)  size(medsmall)) xtitle(Year) legend(order(1 "CBI increases" 2 "CBI decreases"  ///
		3 "CBI index average")  size(small)) graphregion(fcolor(white))  scheme( s1manual )
		
		
		
		
****************************
*Figure 2: Regional average and number of reforms, by component
****************************

use "/Users/.../Reversals_collapsed data.dta", clear

sort year
		
twoway (bar ceo_inc year, sort fcolor(gs10) lcolor(black) barwidth(.75)) ///
	   (bar ceo_dec year, sort fcolor(gs2) lcolor(black) barwidth(.75))  ///
	    (line cuk_ceo year, yaxis(2) lcolor(cranberry) lwidth(medium) lpattern(solid)),  ///
        ytitle(Average CEO component, axis(2)  size(medium)) yline(0, lcolor(black)) yscale(range(0(.1)1) axis(2))  ytitle(Number of reforms, size(medium)) xtitle(Year) legend (off) /*legend(order(1 "CEO increases" 2 "CEO decreases") size(small))*/ title (Agent autonomy) graphregion(fcolor(white))  scheme( s1manual )

		graph save "Graph" "/Users/.../ceo.gph", replace

twoway (bar obj_inc year, sort fcolor(gs10) lcolor(black) barwidth(.75)) ///
	   (bar obj_dec year, sort fcolor(gs2) lcolor(black) barwidth(.75))  ///
	    (line cuk_obj year, yaxis(2) lcolor(cranberry) lwidth(medium) lpattern(solid)),  ///
        ytitle(Average objectives component, axis(2)  size(medium)) yline(0, lcolor(black)) yscale(range(0(.1)1) axis(2))  ytitle(Number of reforms, size(medium)) xtitle(Year) legend (off) /*legend(order(1 "Component increases" 2 "Component decreases" 3 "Component average score") size(small))*/ title (Objectives) graphregion(fcolor(white))  scheme( s1manual )

		graph save "Graph" "/Users/.../obj.gph", replace

twoway (bar pol_inc year, sort fcolor(gs10) lcolor(black) barwidth(.75)) ///
	   (bar pol_dec year, sort fcolor(gs2) lcolor(black) barwidth(.75))  ///
	    (line cuk_pol year, yaxis(2) lcolor(cranberry) lwidth(medium) lpattern(solid)),  ///
        ytitle(Average monetary powers component, axis(2)  size(medium)) yline(0, lcolor(black)) yscale(range(0(.1)1) axis(2))  ytitle(Number of reforms, size(medium)) xtitle(Year) legend (off) /*legend(order(1 "CEO increases" 2 "CEO decreases" 3 "Component average score") size(small))*/ title (Scope of delegation: Monetary policy powers) graphregion(fcolor(white))  scheme( s1manual )

		graph save "Graph" "/Users/.../pol.gph", replace
		
twoway (bar limlen_inc year, sort fcolor(gs10) lcolor(black) barwidth(.75)) ///
	   (bar limlen_dec year, sort fcolor(gs2) lcolor(black) barwidth(.75))  ///
	    (line cuk_limlen year, yaxis(2) lcolor(cranberry) lwidth(medium) lpattern(solid)),  ///
        ytitle(Average fiscal powers component, axis(2)  size(medium)) yline(0, lcolor(black)) yscale(range(0(.1)1) axis(2))   ytitle(Number of reforms, size(medium)) xtitle(Year) legend (off) /*legend(order(1 "Component increases" 2 "Component decreases" 3 "Component average score") size(small))*/ title (Scope of delegation: Fiscal powers) graphregion(fcolor(white)) scheme( s1manual )

		graph save "Graph" "/Users/.../lim.gph", replace

		
		graph combine "/Users/.../ceo.gph"  "/Users/.../pol.gph" "/Users/.../lim.gph" "/Users/.../obj.gph", rows (2) iscale(*1) ycommon xsize(18) ysize(10) graphregion(fcolor(white))  

		
		
****************************
* Figure 3: Average inflation and central bank independence
****************************

use "/Users/.../Reversals_collapsed data.dta", clear

sort year
		
gen lvaw_garriga10=lvaw_garriga*10

twoway (line inf year, yaxis(2) lcolor(cranberry) lwidth(medium) lpattern(solid)) ///
	   (line lvaw_garriga10 year, sort lcolor(black) lwidth(medium) lpattern(dash)) /// 
	   (bar increase year, sort fcolor(gs14%50)  lcolor(black) barwidth(.75)) ///
	   (bar decrease year, sort fcolor(gs10) lcolor(black) barwidth(.75)),  ///
        yline(0, lcolor(black)) yscale(range(-350(300)950) axis(2))  ytitle(Number of reforms/Regional CBI, size(medsmall)) ///
		ytitle(Average inflation, axis(2)  size(medsmall)) xtitle(Year) legend(order(1 "Average inflation" 2 "CBI index average (*10)" ///
		3 "CBI increases" 4 "CBI decreases") size(small)) graphregion(fcolor(white)) scheme( s1manual )
				



****************************
* Figure 4: Regular and irregular replacement of central bank governors (Dreher & CBI data)
****************************

use "/Users/.../Reversals_collapsed data.dta", clear

sort year
		
twoway (bar irregularturnoverdummy year, sort fcolor(gs14) lcolor(black) barwidth(.75)) ///
	   (bar regularturnoverdummy year, sort fcolor(gs4) lcolor(black) barwidth(.75)) (line cuk_ceo year, yaxis(2) lcolor(teal) lwidth(medium) lpattern(dash)) ///
	    (line lvaw_garriga year, yaxis(2) lcolor(cranberry) lwidth(medium) lpattern(solid)),  ///
        yline(0, lcolor(black)) yscale(range(-2(.2).8) axis(2))  ytitle(Number of turnovers (bars), size(medsmall)) ///
		ytitle(Average CBI index, axis(2)  size(medsmall)) xtitle(Year) legend(order(1 "Irregular turnover" 2 "Regular turnovers"  ///
		3 "CEO average" 4 "CBI index average") size(small)) graphregion(fcolor(white)) scheme(s1manual)
		
				
	
		
		
****************************
* Figure 5: Regular and irregular turnover of central bank governors, by country (Panels)
****************************
		
use "/Users/.../Reversals_panel Fig5.dta", clear

tsset cowcode year

drop if cowcode==95 //Dreher's data do not include Panama

xtline irregularturnoverdummy, recast(spike) lcolor(gs8) lwidth(medium) lpattern(solid) i(cname) t(year) addplot((spike regularturnoverdummy year , sort  lcolor(black) lwidth(medthick)) (line cuk_ceo year, sort lcolor(black)) (line lvaw_garriga year , sort lcolor(blue) lpattern(vshortdash))) ytitle(CEO/overall CBI index) ttitle(Year) legend(order(1 "Irregular turnover (spike)" 2 "Regular turnover (spike)" 3 "CEO autonomy" 4 "CBI index")) scheme(s1mono) byopts(graphregion(fcolor(none)))  

				
	
****************************
*Figure 6: Reversals in overall central bank independence, by component and direction (decreases, stacked by components_
****************************

use "/Users/.../Reversals_collapsed_reversals only.dta", clear
 **  collapsed data by year, keep direction==-1 before collapsing

		
graph bar (sum) limlen_dec pol_dec obj_dec ceo_dec ceo_inc, over(year, label(labsize(vsmall))) ///
bar(1, color(black)) bar(2, color(gs8) lcolor(black)) bar(3, color(gs12)  lcolor(black)) bar(4, color(gs14) lcolor(black)) bar(5, color(white) lcolor(black))  stack nolabel yline(0, lcolor(black))  ytitle(Number of reformed components)legend(rows(3) size(medsmall)) legend(order(1 "Fiscal powers (decrease)" 2 "Monetary policy powers (decrease)" 3 "Objectives (decrease)" 4 "CEO autonomy (decrease)" 5 "CEO autonomy (increase)") size(small)) graphregion(fcolor(white)) scheme(s1mono)
		


